#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/utils.mk
include /usr/share/cdbs/1/rules/patchsys-quilt.mk

ifneq (,$(filter mips mipsel, $(DEB_HOST_ARCH)))
  CFLAGS = -Wall -g0 $(DEB_OPT_FLAG)
endif


common-build-arch::
	grep -v -e alsa -e evdev -e udev debian/pulseaudio.install > \
	    debian/pulseaudio.install.kfreebsd-i386
	grep -v -e alsa -e evdev -e udev debian/pulseaudio.install > \
	    debian/pulseaudio.install.kfreebsd-amd64
	grep -v -e alsa -e evdev -e udev debian/pulseaudio.install > \
	    debian/pulseaudio.install.hurd-i386

common-install-arch::
	find $(DEB_DESTDIR) -name "*.la" -delete
	mkdir -p $(CURDIR)/debian/tmp/usr/share/lintian
	cp -a $(CURDIR)/debian/overrides $(CURDIR)/debian/tmp/usr/share/lintian

common-configure-arch::
ifneq (,$(findstring $(DEB_HOST_ARCH), "arm armel"))
	make -C src libpulsecore_0.9.21_la-svolume_arm.lo CFLAGS+=-march=armv6
endif

pulseaudio-install-arch::
	dh_installman --language=C debian/tmp/usr/share/man/man5/default.pa.5

common-binary-post-install-arch:: list-missing

clean::
	rm -f debian/pulseaudio.install.kfreebsd-i386
	rm -f debian/pulseaudio.install.kfreebsd-amd64
	rm -f debian/pulseaudio.install.hurd-i386

update-patch-series:
	mkdir -p $(CURDIR)/debian/patches
	rm -f $(CURDIR)/debian/patches/*.patch
	git format-patch -o $(CURDIR)/debian/patches patches ^upstream | \
		xargs -n 1 basename > $(CURDIR)/debian/patches/series
	for patch in $$(ls $(CURDIR)/debian/patches/*.patch) ; \
	do \
		lines=$$(cat $$patch | wc -l) ; \
		head -n $$(($$lines - 3)) $$patch > $${patch}.chomped ; \
		mv $${patch}.chomped $$patch ; \
	done

ifneq (,$(findstring $(DEB_HOST_ARCH_OS), "linux"))
  DEB_CONFIGURE_EXTRA_FLAGS = --enable-hal-compat --disable-hal
endif

DEB_DH_MAKESHLIBS_ARGS_ALL = --exclude=usr/lib/pulse-0.9.21/modules
DEB_DH_SHLIBDEPS_ARGS_libpulse0 = -u -L/dev/null
DEB_DH_SHLIBDEPS_ARGS_pulseaudio = -u -Ldebian/shlibs_pulseaudio.local
DEB_DH_INSTALL_ARGS = --sourcedir=$(CURDIR)/debian/tmp
DEB_UPDATE_RCD_PARAMS = start 25 2 3 4 5 . stop 15 1 .
